<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="Containers">
<meta name="DC.subject" content="Containers">
<meta name="keywords" content="Containers">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/title.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/concurrent_hash_map.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/concurrent_vector.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/Concurrent_Queue_Classes.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/Summary_of_Containers.htm">
<meta name="DC.Relation" scheme="URI" content="Task-Based_Programming.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="tutorial_Containers">
<link rel="stylesheet" type="text/css" href="../intel_css_styles.css">
<title>Containers</title>
<xml>
<MSHelp:Attr Name="DocSet" Value="Intel"></MSHelp:Attr>
<MSHelp:Attr Name="Locale" Value="kbEnglish"></MSHelp:Attr>
<MSHelp:Attr Name="TopicType" Value="kbReference"></MSHelp:Attr>
</xml>
</head>
<body id="tutorial_Containers">
 <!-- ==============(Start:NavScript)================= -->
 <script src="..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
 <script language="JavaScript1.2" type="text/javascript">WriteNavLink(1);</script>
 <!-- ==============(End:NavScript)================= -->
<a name="tutorial_Containers"><!-- --></a>

 
  <h1 class="topictitle1">Containers</h1>
 
   
  <div> 
	 <p>Intel&reg; Threading Building Blocks (Intel&reg; TBB) provides highly concurrent
		container classes. These containers can be used with raw Windows* OS or Linux*
		OS threads, or in conjunction with task-based programming. 
	 </p>
 
	 <p>A concurrent container allows multiple threads to concurrently access
		and update items in the container. Typical C++ STL containers do not permit
		concurrent update; attempts to modify them concurrently often result in
		corrupting the container. STL containers can be wrapped in a mutex to make them
		safe for concurrent access, by letting only one thread operate on the container
		at a time, but that approach eliminates concurrency, thus restricting parallel
		speedup. 
	 </p>
 
	 <p>Containers provided by Intel&reg; TBB offer a much higher level of
		concurrency, via one or both of the following methods: 
	 </p>
 
	 <ul type="disc"> 
		<li> 
		  <p><strong>Fine-grained locking:</strong> Multiple threads operate on the
			 container by locking only those portions they really need to lock. As long as
			 different threads access different portions, they can proceed concurrently. 
		  </p>
 
		</li>
 
		<li> 
		  <p><strong>Lock-free techniques:</strong> Different threads account and correct
			 for the effects of other interfering threads. 
		  </p>
 
		</li>
 
	 </ul>
 
	 <p>Notice that highly-concurrent containers come at a cost. They
		typically have higher overheads than regular STL containers. Operations on
		highly-concurrent containers may take longer than for STL containers.
		Therefore, use highly-concurrent containers when the speedup from the
		additional concurrency that they enable outweighs their slower sequential
		performance. 
	 </p>
 
	 <div class="Note"><h3 class="NoteTipHead">
					Caution</h3> 
		<p>As with most objects in C++, the constructor or destructor of a
		  container object must not be invoked concurrently with another operation on the
		  same object. Otherwise the resulting race may cause the operation to be
		  executed on an undefined object. 
		</p>
 
	 </div> 
  </div>
 
  
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../tbb_userguide/title.htm">Intel&reg; Threading Building Blocks (Intel&reg; TBB) User Guide</a></div>
</div>
<div class="See Also">
<ul class="ullinks">
<li class="ulchildlink"><a href="../tbb_userguide/concurrent_hash_map.htm">concurrent_hash_map</a><br>
</li>
<li class="ulchildlink"><a href="../tbb_userguide/concurrent_vector.htm">concurrent_vector</a><br>
</li>
<li class="ulchildlink"><a href="../tbb_userguide/Concurrent_Queue_Classes.htm">Concurrent Queue Classes</a><br>
</li>
<li class="ulchildlink"><a href="../tbb_userguide/Summary_of_Containers.htm">Summary of Containers</a><br>
</li>
</ul>

<h2>See Also</h2>
<div class="linklist">
<div><a href="Task-Based_Programming.htm">Task Based Programming
		  </a></div></div>
</div>

</body>
</html>
